import pytest

from Auto.day02.loan.Loan_Data import Loan_Data
from Auto.day02.loan.Loan_Operation import Loan_Operation
from utils.XLUtils import XLUtils
from utils.ReadYaml import ReadYaml

class Test_Loan(Loan_Operation):
        @pytest.mark.parametrize("username,password,money,days,admin,adpassword",Loan_Data.Loan_Data)
        def test_loan(self,username,password,money,days,admin,adpassword,login_driver,daikuan_and_shenpi):
            result = self.getMoney(login_driver)
            self.assert_money(login_driver,money,result,self.pre_money)

        @pytest.mark.parametrize("username,password,money,days,expect", Loan_Data.daikuan_Data)
        def test_daikuan(self,username,password,money,days,expect,login_driver,daikuan):
            result = self.getResultMSG(login_driver)
            self.assserttitle(login_driver,result,expect)

        #yaml
        @pytest.mark.parametrize("username,password,money,days,admin,adpassword",
                                 ReadYaml.read_yaml("D:\Python\Project\project01\Auto\day02\data.yaml")["Loan_Data"])
        def test_loan(self, username, password, money, days, admin, adpassword, login_driver, daikuan_and_shenpi):
            result = self.getMoney(login_driver)
            self.assert_money(login_driver, money, result, self.pre_money)

        @pytest.mark.parametrize("username,password,money,days,expect",
                                 ReadYaml.read_yaml("D:\Python\Project\project01\Auto\day02\data.yaml")["daikuan_Data"])
        def test_daikuan(self, username, password, money, days, expect, login_driver, daikuan):
            result = self.getResultMSG(login_driver)
            self.assserttitle(login_driver, result, expect)
        #excel
        @pytest.mark.parametrize("username,password,money,days,admin,adpassword",
                                 XLUtils.read_excel("D:\Python\Project\project01\Auto\day02\data.xlsx","loan_shenpi"))
        def test_loan(self, username, password, money, days, admin, adpassword, login_driver, daikuan_and_shenpi):
            result = self.getMoney(login_driver)
            self.assert_money(login_driver, money, result, self.pre_money)

        @pytest.mark.parametrize("username,password,money,days,expect",
                                 XLUtils.read_excel("D:\Python\Project\project01\Auto\day02\data.xlsx","daikuan"))
        def test_daikuan(self, username, password, money, days, expect, login_driver, daikuan):
            result = self.getResultMSG(login_driver)
            self.assserttitle(login_driver, result, expect)
